function initSightModel(sequelize, DataTypes) {
  const Sight = sequelize.define(
    'Sight', {
    'sightId': {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true,
      allowNull: false,
      comment: '景点ID',
    },
    'name': {
      type: DataTypes.STRING(100),
      allowNull: false,
      unique: true,
      comment: '景点名称',
    },
    'description': {
      type: DataTypes.TEXT,
      allowNull: false,
      comment: '景点描述',
    },
    'address': {
      type: DataTypes.STRING(200),
      allowNull: false,
      comment: '详细地址',
    },
    'openTime': {
      type: DataTypes.STRING(100),
      allowNull: true,
      comment: '开放时间',
    },
    'rating': {
      type: DataTypes.DECIMAL(2, 1),
      allowNull: false,
      defaultValue: 5.0,
      validate: {
        min: 0,
        max: 5
      },
      comment: '评分',//（0-5分）
    },
    'status': {
      type: DataTypes.ENUM('open', 'closed', 'maintenance'),
      allowNull: false,
      defaultValue: 'open',
      comment: '景点状态',//open-开放，closed-关闭，maintenance-维护中
    },
    'images': {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '景点图片URLs',
      get() {
        const rawValue = this.getDataValue('images');
        return rawValue ? JSON.parse(rawValue) : [];
      },
      set(value) {
        this.setDataValue('images', JSON.stringify(value));
      }
    },
    'facilities': {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '设施服务',
      get() {
        const rawValue = this.getDataValue('facilities');
        return rawValue ? JSON.parse(rawValue) : [];
      },
      set(value) {
        this.setDataValue('facilities', JSON.stringify(value));
      }
    },
    'notice': {
      type: DataTypes.TEXT,
      allowNull: true,
      comment: '参观须知'
    },
    'favoriteCount': {
      type: DataTypes.INTEGER,
      allowNull: false,
      defaultValue: 0,
      comment: '收藏数'
    }
  }, {
    tableName: 'sights',
    indexes: [
      {
        name: 'idx_rating',
        fields: ['rating']
      }
    ]
  });

  // 类方法

  Sight.findTopRated = function(limit = 10) {
    return this.findAll({
      order: [['rating', 'DESC']],
      limit
    });
  };

  return Sight;
}
module.exports = initSightModel;